package com.framework.res;

import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.log4j.Logger;

public class Funcion_getEdad {
	
	public static Logger log = Logger.getLogger(Funcion_getEdad.class);
	
	public static String getDias(Date birth){
        long diff = Calendar.getInstance().getTimeInMillis() - birth.getTime(); //milisegundos de vida
        long sobra = diff % 86400000l;
        diff -= sobra; //con esto ya tenemos puros dias
        long dias = diff / 86400000l ;
        return  dias + " días";
    }
    
	public static String getMeses(Date birth){
        long diff = Calendar.getInstance().getTimeInMillis() - birth.getTime(); //milisegundos de vida
        long sobra = diff % 86400000l;
        diff -= sobra; //con esto ya tenemos puros dias
        long dias = diff / 86400000l ;
        return  new DecimalFormat("#").format(dias / 365d * 12d) + " Meses"; 
    }
	
	
	public static double getMesesLong(Date birth){
        long diff = Calendar.getInstance().getTimeInMillis() - birth.getTime(); //milisegundos de vida
        long sobra = diff % 86400000l;
        diff -= sobra; //con esto ya tenemos puros dias
        long dias = diff / 86400000l ;
        return  ((dias / 365d) * 12d); 
    }
    
    
	public static String getYears(Date birth){
        long diff = Calendar.getInstance().getTimeInMillis() - birth.getTime(); //milisegundos de vida
        long sobra = diff % 86400000l;
        diff -= sobra; //con esto ya tenemos puros dias
        long dias = diff / 86400000l ;
        return  new DecimalFormat("#").format(dias / 365d); 
    }
}
